using System;
using UnityEngine.SceneManagement;
using Voodoo.Pattern;

public class CityBuilderButton : ShopButton
{
	public CityBuildingElementData FirstBuildingData;

	private void Awake()
	{
		GameManager instance = SingletonMB<GameManager>.Instance;
		instance.OnGameEnd = (Action)Delegate.Combine(instance.OnGameEnd, new Action(RefreshNotif));
	}

	private void OnDestroy()
	{
		if (SingletonMB<GameManager>.Instance != null)
		{
			GameManager instance = SingletonMB<GameManager>.Instance;
			instance.OnGameEnd = (Action)Delegate.Remove(instance.OnGameEnd, new Action(RefreshNotif));
		}
	}

	private void RefreshNotif()
	{
		SwitchNotification(FirstBuildingData.Unlocked && FirstBuildingData.ShowNotification());
	}

	public void TryToShow()
	{
		int @int = NintendoPlayerPrefs.GetInt("Level", 0);
		base.gameObject.SetActive(@int >= 1 && Preloader.CityBuilderConfig.IsEnabled);
		SwitchNotification(FirstBuildingData.Unlocked && FirstBuildingData.ShowNotification());
	}

	public override void OnCLick()
	{
		SceneManager.LoadScene("CityBuilder");
	}
}
